// animationHelper.ts
export default {
  createAnimation: function(duration: number, timingFunction: timingFunction) {
    return wx.createAnimation({
      duration: duration,
      timingFunction,
    });
  },

  showAnimation: function(animation: any, translateY: number, setData: Function, showKey: string) {
    animation.translateY(translateY).step();
    setData({
      animationData: animation.export(),
      [showKey]: true
    });
    setTimeout(() => {
      animation.translateY(0).step();
      setData({
        animationData: animation.export(),
      });
    }, 50);
  },

  closeAnimation: function(animation: any, translateY: number, setData: Function, showKey: string) {
    if (animation) {
      animation.translateY(translateY).step();
      setData({
        animationData: animation.export(),
      });
      setTimeout(() => {
        animation.translateY(0).step();
        setData({
          animationData: animation.export(),
          [showKey]: false
        });
      }, 400);
    }
  }
}